package com.changgou.cg.controller;

import com.changgou.cg.service.PageService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping(value="/page")
public class PageController {
    @Autowired
    private PageService pageService;
    @RequestMapping(value ="/createHtml/{id}")
    public Result createHtml(@PathVariable(value="id") Long spuId){
        pageService.createPageHtml(spuId);
        return new Result(true, StatusCode.OK,"OK");
    }

    /**
     * 删除静态页面
     *
     * @param id
     * @return
     */
    @RequestMapping("/deleteHtml/{id}")
    public Result deleteHtml(@PathVariable(name = "id") Long id) {
        pageService.deletePageHtml(id);
        return new Result(true, StatusCode.OK, "删除成功");
    }
}
